using Godot;
using System;

public partial class ActionMove : BTLeaf
{
    public override void run()
    {
        base.run();
		Characters parentOfType = FindParentOfType<Characters>(this);
		_character = parentOfType;
		Vector2I dir = (Vector2I)(_character.targetPos - _character.GlobalPosition);
		_character._moveDirection = dir.Sign();
		if(_character._stateMachine.current_state == (int)Characters.State.SKILL)
		{
			EmitSignal(SignalName.completed,faile());
			return;
		}
		_stateMachine.current_state = (int)Characters.State.RUN;
		//await ToSignal(_character._timer, Timer.SignalName.Timeout);
		//_character.GlobalPosition = _character.targetPos;
		//GD.Print("转移");
		//GD.Print(_character.Name,"角色位置：" , _character.GlobalPosition);
		//_character._timer.Start(-1);
		
		EmitSignal(SignalName.completed,succeed());
    }
}
